package com.ddc.study.base;

import android.os.Bundle;

import androidx.annotation.LayoutRes;
import androidx.annotation.Nullable;

/**
 * Created on 2018/5/21.
 *
 * @author lshun
 * @version 1.0
 */
public abstract class MvpActivity<V extends BaseView, T extends BasePresenter<V>> extends BaseActivity implements BaseView {
    protected T mPresenter;

    protected abstract T createPresenter();

    @LayoutRes
    protected abstract int getLayoutRes();

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        mPresenter = createPresenter();
        mPresenter.attachView((V) this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        mPresenter.detachView();
    }

    @Override
    public void runOnUIThread(Runnable runnable) {
        runOnUiThread(runnable);
    }

    @Override
    public final String getStringValue(int resId) {
        return getString(resId);
    }
}
